<div id="content"  style="background-color:#ffffff">
  <div id="content-header">
    <div id="breadcrumb"> <a href="?m=admin&t=main" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 后台首页</a> <a href="#">应用管理</a> <a href="#" class="current">渠道</a> </div>
  </div>
  <div class="container-fluid" style=' margin-top:20px'>
		<fieldset class="layui-elem-field">
			<legend>应用信息</legend>
          <div class="layui-field-box">
            <form class="layui-form " id="form-wizard"  method="post" action="?m=admin&o=app&t=saveApp&id=<{$gvar.fget.id}>">
                <div class="layui-form-item">
                  <label class="layui-form-label">应用名称</label>
                  <div class="layui-input-block">
                 
                    <input class="layui-input" id="username" type="text" name="channel_name" value="<{$data.channel_name}>"/><br />
				  
                  </div>
                </div>

				<div class="layui-form-item">
                  <label class="layui-form-label">渠道方名称</label>
                  <div class="layui-input-block">
                 
                    <select id="channelsite_id" name="channelsite_id">
                      <{section name=list loop=$channel_data}> 
						<option value="<{$channel_data[list].id}>" <{if $channel_data[list].id==$data.channelsite_id}>selected="selected"<{/if}>><{$channel_data[list].channel_name}></option>
                      <{/section}>
                    </select>
				  
                  </div>
                </div>
               
              <div class="layui-form-item">
                  <label class="layui-form-label">资源方</label>
                  <div class="layui-input-block">
                    <select id="resources" name="resources_id" class="select">
                      <{section name=list loop=$resources_data}> <option url='<{$resources_data[list].resources_url}>' value="<{$resources_data[list].id}>" <{if $resources_data[list].id==$data.resources_id}>selected="selected"<{/if}>><{$resources_data[list].resources_name}>
                      </option>
                      <{/section}>
                    </select>
                  </div>
                </div>
               <div class="layui-form-item">
                  <label class="layui-form-label">资源URL</label>
                  <div class="layui-input-block">
                    <input class="layui-input" id="url" type="text"  readonly value="<{$resources_data[0].resources_url}>" placeholder="带http://"/>
                  </div>
                </div>
                 <div class="layui-form-item">
                  <label class="layui-form-label">key</label>
                  <div class="layui-input-block">
                    <input class="layui-input"  id="key" type="text" style="width:300px" value="<{$data.key}>" <{if $data.key}>readonly<{/if}> name="key"/>
                    <{if !$data.key}> <input id="create_key"  class="btn btn-info" type="button" value="生成KEY" /><{/if}>
                  </div>
                </div>
               
    
                <div class="layui-form-item">
                  <label class="layui-form-label">状态</label>
                  <div class="layui-input-block">
						<input id='radio1' title='启用' name="status" type="radio" value="1" <{if $data.status==1 || !$data.status}>checked="checked"<{/if}> />
						<input title='禁用' id='radio2' name="status" type="radio" value="0" <{if $data.status==0}>checked="checked"<{/if}> />
                  </div>
                </div>
               <div class="layui-form-item">
				<div class="layui-input-block">
				  <button class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
				  <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
				</div>
			   </div>
              
            </form>
          </div>
		  </fieldset>
  </div>
</div>
<script>
$(function(){
	
	$("#resources").change(function(){
		
		$("#url").val($(this).find('option:selected').attr('url'));
	})	
	$("#create_key").click(function(){
		
		$("#key").val(getUuid())
	})
	
	function getUuid(){
	  var len=32;//32长度
	  var radix=16;//16进制
	  var chars='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');var uuid=[],i;radix=radix||chars.length;if(len){for(i=0;i<len;i++)uuid[i]=chars[0|Math.random()*radix];}else{var r;uuid[8]=uuid[13]=uuid[18]=uuid[23]='-';uuid[14]='4';for(i=0;i<36;i++){if(!uuid[i]){r=0|Math.random()*16;uuid[i]=chars[(i==19)?(r&0x3)|0x8:r];}}}
	  return uuid.join('');
	}  

})

layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form()
  ,layer = layui.layer
  //,layedit = layui.layedit
  //,laydate = layui.laydate;
  
  //创建一个编辑器
  //var editIndex = layedit.build('LAY_demo_editor');
 
  //自定义验证规则
 
  
  
});
</script>




